#ifndef __PAGE_MANAGER_H__
#define __PAGE_MANAGER_H__

#include <stdint.h>

typedef void(*CallbackFunction_t)(void);
typedef void(*EventFunction_t)(void*,int);

typedef struct {
    CallbackFunction_t SetupCallback;
    CallbackFunction_t LoopCallback;
    CallbackFunction_t ExitCallback;
    EventFunction_t EventCallback;
} PageList_TypeDef;


#define IS_PAGE(page)   ((page)<(MaxPage))

#ifndef NULL
#   define NULL 0
#endif


#ifndef true
#define true	1
#define false	0
#endif

#define PAGE_STACK_SIZE 10

void page_manager_init(PageList_TypeDef *_PageList, uint8_t _MaxPage);
uint8_t page_register(
            uint8_t _PageID,
            CallbackFunction_t _SetupCallback,
            CallbackFunction_t _LoopCallback,
            CallbackFunction_t _ExitCallback,
            EventFunction_t _EventCallback);
uint8_t page_clear(uint8_t _PageID);
void page_stack_clear(void);
void page_change_to(uint8_t _PageID);
void page_event_transmit(void *obj, int event);
uint8_t page_push(uint8_t _PageID);
uint8_t page_pop(void);
void page_run(void);


#endif
